export default {
  setStorage(value, key = "sessionId") {
    const params = {
      date: new Date().getTime(),
      value
    };
    wx.setStorageSync(key, JSON.stringify(params));
  },
  getStorage(minutes = 30, key = "sessionId") {
    let obj = wx.getStorageSync(key);
    if (!obj) {
      return null
    }
    obj = JSON.parse(obj);
    const date = new Date().getTime();
    if (date - obj.date > 1800000 * minutes) return null;
    return obj.value;
  },
  removeStorage(key){
    wx.removeStorageSync(key);
  }
}
